/* eslint valid-jsdoc: "off" */
/**
 * @author karry
 * @param 当前生产环境
 */
 'use strict';
 const os = require('os');
 module.exports = (appInfo) => {
   const config = (exports = {});
   config.keys = appInfo.name + '_stacy';
   config.middleware = [];
   // 微信小程序信息配置
   config.weixin = {
     stacy: {
       appid: 'wxfd38a260f48bed3f',
       secret: 'ca74dfee4b6d7c68a5bc29c5ef22d9a0',
     },
     mchId: '1606040193', //商户号
     mchKey: 'FmONcRub2KLpeKmKF7mjcBWcmwDdEBNv', //API密钥
   };
 
   config.middleware = ['httpLog'];
   config.session = {
     key: 'stacy', //设置session的名称
     httpOnly: true, //是否由服务器来控制
     maxAge: 1000 * 60 * 60, //设置session的过期时间
     renew: true, //
   };
   config.sequelize = {
     dialect: 'mysql',
     host: '127.0.0.1',
     port: 3306,
     user: 'stacy',
     password: 'root',
     database: 'stacy',
     logging: true,
     timezone: '+08:00',
     dialectOptions: {
       // 让读取date类型数据时返回字符串而不是UTC时间
       dateStrings: true,
       typeCast(field, next) {
         if (field.type === 'DATETIME') {
           return field.string();
         }
         return next();
       },
     },
     define: {
       freezeTableName: true, //false为复数形式+s
       paranoid: false, // 添加软删除
       timestamps: true, // 添加create,update,delete时间戳
       underscored: true, // 字段是否是下划线
     },
   };
 
   config.jwt = {
     secret: 'karry', //加盐等于自己的签名
   };
   const userConfig = {
     salt: 'karry',
     redisExpire: 60 * 60 * 24,
   };
   userConfig.security = {
     csrf: false,
     domainWhiteList: ['*'], //白名单IP无跨域问题
   };
   config.redis = {
     client: {
       port: 6379, // Redis port
       host: '127.0.0.1', // Redis host
       password: 'auth',
       db: 0,
     },
   };
 
   config.io = {
     namespace: {
       '/': {
         connectionMiddleware: ['connection'],
         packetMiddleware: [],
       },
     },
   };
   config.swaggerdoc = {
     dirScanner: './app/controller',
     apiInfo: {
       title: 'Stacy接口文档',
       description: '接口文档',
       version: '1.0.0',
     },
     schemes: ['http', 'https'],
     consumes: ['application/json'],
     produces: ['application/json'],
     securityDefinitions: {},
     enableSecurity: false,
     routerMap: false,
     enable: true,
   };
   userConfig.multipart = {
     mode: 'stream',
     whitelist: [
       '.png',
       '.jpeg',
       '.jpg',
       '.gif',
       '.docx',
       '.doc',
       '.pdf',
       '.mp4',
     ],
     fileSize: '50mb',
   };
 
   userConfig.jwtSecret = 'karry';
   return {
     ...config,
     ...userConfig,
   };
 };
 